<script setup name="site-index">
import { ref } from 'vue';
import logo from '@/assets/logo.png';
import aboutUsLogo from "@/assets/ct.jpg";
import {getNowTimeStrWithFormatter} from "@/utils/util";
import likeIcon2 from "@/assets/like_s.png";
import router from '@/router';
import { isIos, isAndroid, isQQ } from "@/utils/util";
import { util } from "@/utils/util";

// 是否来自移动端
let isMobile = isQQ() || isAndroid() || isIos()
console.log('isMobile:', isMobile);

let deviceW = util.getAppWidth();

const selectIndex = ref(0);
const tabs = ref([
  {
    label:"关于我们",
    name:0,
  },
  {
    label:"发展历程",
    name:1,
  },
  {
    label:"联系我们",
    name:2,
  },
]);

// 关于我们说明内容
const aboutUsText = "开运数字物流平台以大宗商品运输为切入点，利用人工智能、车联网等新兴的技术手段，运用互联网对货主、车主、司机等所有数据进行整合和分析，解决传统物流行业中，货主和车主交易信息不对称，双方信用体系不健全，支付结算体系风险巨大，车主和货主的运营成本高等行业痛点； 通过数字物流平台，车货双方的实名认证，采用线上接单模式降低货主运营成本，海量货源提高司机接单率，并利用第三方支付，形成交易信用体系，保障货物运输的安全、高效、便捷。通过对运输交易全过程的信息记录，不断优化交易过程，提高交易效率。通过不断接入第三方服务，一站式为司机解决吃住行修、保险金融等服务，为司机提供油气、保险等汽车后市场的服务。 基于数字物流平台的车联网技术，对运输中的货物和车辆进行全领域跟踪，并将数据实时上传至监控中心，使得整个运输实现跟踪管理。依托这个监控网络，可以让托运人在实际运输途中实时掌握车辆动态和货物状态，实现物流场景可视化和全程可追溯，为交易的真实性提供依据，确保了运输过程中的安全性、可控性。"

// 卡片urls
const cardItmes = [
  {
    style:'background-image:url("https://www-static.qbox.me/_next/static/media/bg1.6953c5d29b0c59aa80e41e27023e44c5.png");background-position: top;',
    title:'低门槛介入',
    des:'提供各种音视频能力SDK和可视化的方案配置，大幅降低音视频开发门槛，助力企业以更低成本和更高效率搭建专属的音视频应用'
  },
  {
    style:'background-image:url("https://www-static.qbox.me/_next/static/media/bg2.1eba51cba2878f2db1615656a04d78fd.png");background-position: bottom;',
    title:'可扩展性强',
    des:'开源所有 UI 组件，您可按自己的需求快速个性化改造'
  },
  {
    style:'background-image:url("https://www-static.qbox.me/_next/static/media/bg3.64c525272494d1bcc00bed6fc2dc1c54.png");background-position: top;',
    title:'全场景支持',
    des:'覆盖泛娱乐互动直播、电商直播带货、语聊房在线教育等多应用场景。'
  },
  {
    style:'background-image:url("https://www-static.qbox.me/_next/static/media/bg4.4f97e5d8177390bb7d0219ecc0964127.png");background-position: bottom;',
    title:'一站式方案管理',
    des:'提供基于解决方案的控制台管理平台，可以对创建的音视频应用进行统一管理，提升管理安全性和效率'
  }
]

// 卡片配置数据
const cardConfig = {
  // 数据源
  data:[],
  // 列间隔
  gutter:10,
  // 多少列
  totalColum: isMobile ? 1 : 3,
  // 每列占据的份额
  span:isMobile ? 24: 8,
}
let date = getNowTimeStrWithFormatter()
for (let i= 0; i < 3; i += 1) {
  let cardObj = {
    title:'万合',
    des:'开运物流低代码方案帮助万合网快速实现物流全过程监测等功能开发，为万合网“应用驱动，产品致胜”的发展理念提供支撑。',
    date,
    image:"https://wlhyos-prod.oss-cn-hangzhou.aliyuncs.com/1491508d58abe06bea26c2bc465b585a.png?Expires=169832268",
    icon:likeIcon2,
  }
  if (i == 1) {
    cardObj.title = '货车慧';
    cardObj.des ='开运物流低代码方案帮助货车慧网快速实现物流全过程监测等功能开发，为万合网“应用驱动，产品致胜”的发展理念提供支撑。';
    cardObj.image = 'https://img.zcxxkj.xin/10081/20200618/47200b960d05c936f9c61261b0d72268.png?OSSAccessKeyId=LTAI5t8JT8N41fGuHkadXB8s&Expires=1699669646&Signature=f200S5cnOA35eahVH3F1ZrdH8IM%3D'
  } else if (i == 2) {
    cardObj.title = '华佑货运';
    cardObj.des ='开运物流低代码方案帮助华佑货运网快速实现物流全过程监测等功能开发，为万合网“应用驱动，产品致胜”的发展理念提供支撑。';
    cardObj.image = 'https://oss.56fanyun.com/ttms/44cdfea046f84053af7a6d80283b77cf.png'
  }
  cardConfig.data.push(cardObj);
}

let showDrawer = ref(false);



/**
 * 获取
 * @param index
 * @returns {string}
 */
const getCustomerImageClass = (index) => {
  if (index == 1 || index == 2) {
    return 'image-khy';
  }
  return 'image';
}

/**
 * 顶部tab栏按钮点击事件
 * @param tab
 * @param event
 */
const handleTabClick = (index) => {
  console.log('顶部tab栏切换：', index);
  let isLast = index == tabs.value.length - 1;
  if(!isLast) {
    // 联系我们时 当前页面主内容不变
    selectIndex.value = index;
  }

  // 是否显示联系我们抽屉
  showDrawer.value = isLast;
}

/**
 * 客户卡片点击事件
 */
const cardClick = () => {
  console.log('卡片点击事件')
}

/**
 * 下拉框点击事件
 */
const handleCommand = (index) => {
  handleTabClick(index);
}

</script>

<template>
  <page-view class="container">
    <template v-slot:header>
      <div class="nav">
        <div class="left">
          <div style="display: flex;align-items: center">
            <img class="logo" :src="logo" alt="">
            <span style="margin-left: 10px">开运数字物流</span>
          </div>
        </div>
        <div class="right" v-if="!isMobile">
          <div
              v-for="(item, index) in tabs"
              :class="['right-btn', 'blue-hover-btn', { 'blue-text-btn': selectIndex == index }]"
              :key="index"
              @click="handleTabClick(index)"
          >
            {{item.label}}
          </div>
        </div>
        <div v-else>
          <el-dropdown @command="handleCommand">
            <span class="el-dropdown-link">
              <el-icon class="el-icon--right"><arrow-down /></el-icon>
            </span>
            <template #dropdown>
              <el-dropdown-menu
                  v-for="(item, index) in tabs"
                  :key="index"
              >
                <el-dropdown-item :command="index">{{item.label}}</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </div>
    </template>
    <template v-slot:default>
      <div v-if="selectIndex == 0" class="content">

        <div class="title">平台简介</div>
        <div :class="isMobile ? 'about-us-mobile' : 'about-us'">
          <img :src="aboutUsLogo" :width="isMobile ? deviceW : '500'" alt="">
          <div>{{aboutUsText}}</div>
        </div>

        <div class="title">平台能力</div>
        <div class="des">提供高效、可复用、多场景覆盖的平台能力</div>
        <div class="items">
          <div class="card"
               v-for="(item, index) in cardItmes"
               :key="index"
               :style="item.style"
          >
            <div :class="index%2 == 0 ? 'card-intro-bottom' : 'card-intro-top'">
              <div class="card-intro-num">0{{index + 1}}</div>
              <div class="card-intro-title">{{item.title}}</div>
              <div class="card-intro-des">{{item.des}}</div>
            </div>
          </div>
        </div>

        <div class="title">快速集成</div>
        <div class="step-intro">只要三步，可快速使用智慧物流平台</div>
        <div>
          <div class="step">
            <div class="step-item">01.选择场景</div>
            <el-icon><ArrowRight /></el-icon>
            <div class="step-item">02.配置模板</div>
            <el-icon><ArrowRight /></el-icon>
            <div class="step-item">03.启动应用</div>
          </div>
        </div>

        <div class="title">客户案例</div>
        <el-row :class="isMobile ? 'customer-row-block' :'customer-row-flex'" :gutter="10">
          <el-col
              v-for="(item, index) in cardConfig.data"
              :key="index"
              :span="cardConfig.span"
          >
            <el-card @click="cardClick" class="customer-card">
              <div class="card-header">
                <img
                    :class="getCustomerImageClass(index)"
                    :src="item.image"
                />
              </div>
              <div style="padding: 14px">
                <span class="customer-name">{{item.title}}</span>
                <div class="card-bottom">
                  <div class="customer-intro">{{item.des}}</div>
                </div>
              </div>
            </el-card>
          </el-col>
        </el-row>

      </div>
      <develop-trend v-else-if="selectIndex == 1"></develop-trend>
      <el-drawer
          :size="isMobile ? '100%' : '30%'"
          v-model="showDrawer"
          title="联系我们"
          :with-header="true"
      >
        <join-us></join-us>
        <h4>公司地址：武汉东湖新技术开发区光谷大道特1号国际企业中心三期1栋4层03号G490室（自贸区武汉片区）</h4>
        <h4>电话：027-87002591</h4>
        <h4>邮箱：87002591@qq.com</h4>
        <h4>联系人：吴开</h4>
      </el-drawer>
    </template>

  </page-view>
</template>

<script>
import developTrend from "./develop-trend";
import joinUs from './join-us'
export default {
  name: "index",
  components: {developTrend, joinUs}

}
</script>

<style lang="scss" scoped>
@import "../../assets/styles/public.scss";

* {
  box-sizing: border-box;
}

.container {
  background-color: #f8f8f8;
  color: #333;
  padding: 0;
  margin: 0;
}

/*头部区域*/
.nav {
  display:flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  box-sizing: border-box;
  background: #ffffffcc;

  .left {
    .logo {
      width: 64px;
      height: 64px;
      display: block;
      margin: auto 0;
    }
  }

  .right {
    display: flex;
    .right-btn {
      font-size: 15px;
      width: 80px;
      text-align: center;
    }

    .right-btn-s {
      color: #2478FF;
    }
  }
}

@media only screen and (max-width: 767px) {
  .content {
    width: 767px;
  }
}

@media only screen and (max-width: 414px) {
  .content {
    width: 414px;
  }
}

@media only screen and (max-width: 375px) {
  .content {
    width: 375px;
  }
}

/*内容区*/
.content {
  width: 1420px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  text-align: center;

  .title {
    height: 80px;
    line-height: 80px;
    text-align: center;
    color: rgb(51, 51, 51);
    font-size: 28px;
  }

  .des {
    color: #666;
    line-height: 22px;
    margin-bottom: 15px;
  }

  .about-us, .about-us-mobile {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 10px;
    background-color: white;
    line-height: 2;
    color: #999999;
    margin-bottom: 10px;
  }

  .about-us-mobile {
    display: block;
  }

  // 卡片部分
  .items {
    display: flex;
    align-content: center;
    align-items: center;
    text-align: left;
    justify-content: center;

    // 单个卡片
    .card {
      -webkit-box-flex: 1;
      -ms-flex: 1;
      // 均分
      flex: 1;
      position: relative;
      text-align: left;
      background-size: contain;
      background-repeat: no-repeat;
      height: 480px;
      font-size: 18px;
      font-weight: 500;
      text-align: left;
    }

    // 图片底部的描述区域
    .card-intro-bottom, .card-intro-top {
      position: absolute;

      left: 0;
      right: 0;
      padding: 40px;
      height: 180px;
      -webkit-transition: all .25s ease-in-out;
      transition: all .25s ease-in-out;
    }

    .card-intro-bottom {
      color: #fff;
      background: #000;
      bottom: 0;
    }

    .card-intro-top {
      color: #000;
      background: #fff;
      top: 0;
    }

    // 数字
    .card-intro-num {
      width: 34px;
      height: 33px;
      font-size: 26px;
      font-weight: 800;
    }

    // 标题
    .card-intro-title {
      margin: 12px 0;
    }

    // 描述
    .card-intro-des {
      color: #fff;
      opacity: 0;
      -webkit-transition: all .25s;
      transition: all .25s;
      font-size: 14px;
      display: none;
    }

    // 单个卡片高亮时
    .card:hover {

      .card-intro-title, .card-intro-num {
        color: #fff !important;
      }

      .card-intro-des {
        opacity: 1;
        display: block;
      }

      // 背景视图需要有明确的数值变化才会有过渡效果
      .card-intro-bottom, .card-intro-top {
        background-color: #07beff !important;
        height: 328px;
      }
    }
  }

  // 步骤部分
  .step-intro {
    font-size: 24px;
    font-weight: 500;
    text-align: left;
    margin-bottom: 15px;
  }

  .step {
    display: flex;
    align-items: center;

    .step-item {
      flex: 1 1 0px;
      margin: 0px 12px;
      text-align: left;
      padding-left: 36px;
      height: 60px;
      line-height: 60px;
      box-sizing: border-box;
      border-radius: 2px;
      border: 1px solid rgb(238, 238, 238);
      box-shadow: rgba(51, 51, 51, 0.08) 0px 4px 8px 0px;
    }

    .step-item:first-child {
      margin-left: 0;
    }
  }
}

// 客户案例
.customer-row-block {
  display: block;
  padding: 10px;
}

.customer-row-flex {
  display: flex;
  padding: 10px;
}

.customer-card {
  // 使得放大效果更加平滑
  transition: transform 0.3s ease-in-out;
  margin-bottom: 10px;

  .card-header {
    display: flex;
    height: 100px;
  }

  .image {
    width: 100%;
    display: block;
    margin: auto 0;
  }

  // 快货运公司图标
  .image-khy {
    display: block;
    margin: auto;
    width: 80px;
  }

  // 卡片底部
  .card-bottom {
    margin-top: 15px;
    line-height: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 120px;
  }

  // 客户名称
  .customer-name {
    font-size: 20px;
    font-weight: 500;
  }

  // 客户赞赏文案
  .customer-intro {
    color: #666;
    line-height: 1.5715;
    font-size: 14px;
  }
}

.customer-card:hover {
  // 鼠标放上去 放大到原始大小的1.1倍
  transform: scale(1.02, 1.02);
  //margin-top: -5px;
  border-color: $danger-color;
}

</style>
